export default /* glsl */`
varying vec2 vUv;
//uniform sampler2D map;
uniform bool flip;
uniform vec3 color;

float sdSegment( in vec2 p, in vec2 a, in vec2 b ) {
    vec2 pa = p-a, ba = b-a;
    float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
    return length( pa - ba*h );
}
  
void main() {
    //vec4 tColor = texture2D(map, vUv);
    vec2 p = fract(vUv);
    p = p * 2.0 - 1.0;
    if (flip) {
        p.x = -p.x;
    }
    float d1 = sdSegment(p, vec2(0.5, 0.0), vec2(0.0, 0.45));
    float d2 = sdSegment(p, vec2(0.5, 0.0), vec2(0.0, -0.45));
    float d = min(abs(d1), abs(d2));

    float a1 = 1.0;
    // float a2 = 1.0 - smoothstep(0.23, 0.233, d);
    vec4 color1 = vec4(vec3(1.0), a1);
    // vec4 color2 = vec4(vec3(0.0), a2);
    // gl_FragColor = vec4(color1.xyz * a1 + color2.xyz * a2, clamp(a1 + a2, 0.0, 1.0) );
    gl_FragColor = vec4(vec3(color.x/255.0, color.y/255.0, color.z/255.0), a1);
}
    `;
